local ClientOHOH = _G.ClientOHOH;
local M = ClientOHOH.class.new(script, ClientOHOH.files.Client_PlayerComponent(),script.Parent.Name);
local EventList = ClientOHOH.load.EventList();
-- local NpcGui=ClientOHOH.load.UIManager().ui_list.NpcTipGui
-- local HomeGui=ClientOHOH.load.UIManager().ui_list.HomeGui

local LanguageHelper=_G.LanguageHelper 

function M.new(self,...)
	return M(self,...);
end;

local GuidData={
    [1]={
      fuc="TrianGuide",
      tip=530001,
      power=50000,
    },

    -- [2]={
    --     fuc="GoToBattle",
    -- },
    -- [3]={
    --     fuc="MakeTvMan",
    -- },
}

function M.ctor(self, parent)
	M.super.ctor(self, parent);
    -- self.DataBase=self.parent:GetComponent(ClientOHOH.load.Client_PlayerDataComponent());
    -- self:AddProcess(function()
    --     while not self.parent.character do
    --         self:Wait(1.5)
    --     end
    --     self:Wait(1)
    --     self.guidId=self.DataBase:GetData("guide")
    --     if not self.guidId then
    --         self.guidId=1
    --     end
    --     self:BindGuide()
    -- end)

    self.parent:AddPrivateComponentByFolder(script.Parent.HomeButton)
    self.parent:AddPrivateComponentByFolder(script.Parent.AddLine)

end;

function M.BindGuide(self)
    if  GuidData[self.guidId] then
        local gdata=GuidData[self.guidId] 
        if gdata.fuc and  M[gdata.fuc] then
            M[gdata.fuc](self,gdata)
        end
    end
end



function M.NextGuide(self)
    self.guidId=self.guidId+1
    self:BindGuide()
    self:Fire(EventList.next_guide)
end

function M.CloseTrianGuide(self,isNotNext)
    -- if not self.TrianGuideConList then
    --     return 
    -- end

    -- for k,v in pairs(self.TrianGuideConList) do
    --     v:Disconnect()
    -- end
    -- self.TrianGuideConList=nil
    -- local beamLine=self.parent:GetComponent(ClientOHOH.load.Client_BeamLineCtrl());
    -- beamLine:DestoryLine("GUDIE_1")
    -- NpcGui:Hide()
    -- HomeGui:Show()
    -- self:NextGuide()
end
function M.TrianGuide(self,data)
    -- self.TrianGuideConList={}
    -- local tip=LanguageHelper:GetText(data.tip,{"%%ARG1"},{data.power})
    -- NpcGui:Show(tip)
    -- local beamLine=self.parent:GetComponent(ClientOHOH.load.Client_BeamLineCtrl());
    
    -- local trianObj=self.parent:GetComponent(ClientOHOH.load.Client_TrianArearCtrl()):GetOneCommonTian()

    -- local tag=trianObj:GetHead()

    -- beamLine:CreateLine(tag,"GUDIE_1")

    -- local con=self.parent.OneTrainEvent:Connect(function()
    --     self:CloseTrianGuide()
    -- end)
    -- table.insert(self.TrianGuideConList,con)
    -- HomeGui:Hide()
    -- local con1=  self:AddProcess(function()
    --     self:Wait(40)
    --     self:CloseTrianGuide()
    -- end)
    -- table.insert(self.TrianGuideConList,con1)

    -- local con3 = self.parent.StartBattle:Connect(function()
    --     self:CloseTrianGuide()
    -- end)
    -- table.insert(self.TrianGuideConList,con3)

end

-- function M.TrianGuide(self,data)

--     if self.DataBase:GetData("base").power>=data.power then
--         self:NextGuide()
--         return 
--     end
--     local tip=LanguageHelper:GetText(data.tip,{"%%ARG1"},{data.power})
--     NpcGui:Show(tip)
--     local beamLine=self.parent:GetComponent(ClientOHOH.load.Client_BeamLineCtrl());
    
--     local lvMg=self.parent:GetComponent(ClientOHOH.load.Client_LevelManangerComponent());
--     local level=lvMg:GetActiveLevel()
--     local trianObj=level:GetComponent(ClientOHOH.load.Client_LevelTrianCtrl()):GetAllTrainObj()[1]
--     local tag=trianObj:GetHead()

--     beamLine:CreateLine(tag,"GUDIE_1")

--     local trainCon=nil
--     local con2=nil
--     con2=trianObj.TrainOpenEvent:Connect(function()
--         if con2 then
--             con2:Disconnect()
--             con2=nil
--         end
--         if trainCon then
--             NpcGui:Show(LanguageHelper:GetText(300005))
--         end
--         beamLine:DestoryLine("GUDIE_1")

--     end)
   
--     trainCon=self.parent.OneTrainEvent:Connect(function()
--         beamLine:DestoryLine("GUDIE_1")
--         if trainCon then
--             trainCon:Disconnect()
--             trainCon=nil
--         end
--         NpcGui:Hide()
--         local userDataChangeCon=nil
--         userDataChangeCon=self.parent.UserDataEvent:Connect(function(udata)
--             if udata["base"] and udata["base"].power>=data.power then
--                 if userDataChangeCon then
--                     userDataChangeCon:Disconnect()
--                     userDataChangeCon=nil
--                 end
--                 self:NextGuide()
--             end
--         end)

     
--     end)
-- end

function M.MakeTvManGuide(self)

end

-- function M.GoToBattle(self,data)
--     NpcGui:Show(LanguageHelper:GetText(530002))

--     local lvMg=self.parent:GetComponent(ClientOHOH.load.Client_LevelManangerComponent());
--     local level=lvMg:GetActiveLevel()
--     local beamLine=self.parent:GetComponent(ClientOHOH.load.Client_BeamLineCtrl());
--     beamLine:CreateLine(level:GetDoor(),"GUDIE_2")
--    local con=nil
--    con = self.parent.StartBattle:Connect(function()
--         beamLine:DestoryLine("GUDIE_2")
--         if con then
--             con:Disconnect()
--             con=nil
--         end
--         NpcGui:Hide()
--         self:NextGuide()
--     end)
    
-- end

function M.dtor(self)
	M.super.dtor(self);
end;

return M